package com.jt.ktdemo.ui.echart

import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import com.jt.ktdemo.R

class EchartActivity : AppCompatActivity() {

    private lateinit var evModule: EchartsView


    @SuppressLint("NewApi")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_echart)
        evModule = findViewById(R.id.evModule);
        evModule.webViewClient = object : WebViewClient() {
            override fun onPageFinished(view: WebView, url: String) {
                super.onPageFinished(view, url)
                refreshLineChart()
            }
        }
    }


    private fun refreshLineChart() {
        val x = arrayOf<Any>(
            "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
        )
        val y = arrayOf<Any>(
            820, 932, 901, 934, 1290, 1330, 1320
        )
        evModule.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y))
    }


}